Skip to content

fix(kiro): run kiro-cli through a PTY so usage loads (fixes #1619)#1744

Merged
steipete merged 6 commits into
steipete:mainfrom
sf-jin-ku:fix/kiro-cli-pty-usage
Jun 26, 2026
Merged

fix(kiro): run kiro-cli through a PTY so usage loads (fixes #1619)#1744
steipete merged 6 commits into
steipete:mainfrom
sf-jin-ku:fix/kiro-cli-pty-usage

Conversation

@sf-jin-ku

@sf-jin-ku sf-jin-ku commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Kiro usage timed out on kiro-cli 2.8.1 even though the same commands returned in seconds from a terminal. Fixes #1619.

kiro-cli performs terminal setup on startup and emits no output when launched over bare pipes. Route whoami, /usage, and /context through the shared PTY runner so GUI and packaged-app probes behave like terminal invocations.

Final behavior

  • Preserve the child process's natural exit status; valid-looking output from a failed command is still a failure.
  • Accept idle /usage output only after complete usage markers have arrived; deadlines and incomplete output still fail.
  • Preserve cancellation and terminate the PTY process group promptly, including helpers left behind after the main process exits.
  • Remove the superseded pipe-backed Kiro command path.

Verification

  • swift test --filter KiroStatusProbeTests — 42 passed
  • swift test --filter TTYCommandRunnerEnvTests — 26 passed
  • swift test --filter SpawnedProcessGroupTests — 12 passed
  • make check — clean
  • make test — 43/43 shards passed
  • Autoreview — no actionable findings
  • Real kiro-cli 2.8.1 and packaged-app proof from the contributor: usage returned in seconds with no residual Kiro processes, and the packaged app populated Kiro usage instead of timing out.

kiro-cli 2.8.1 (an Amazon Q Developer CLI fork) performs terminal setup
on startup and emits no output at all when launched without a controlling
terminal. The probe launched `whoami`, `chat --no-interactive /usage`, and
`/context` over plain pipes, so every command hung until the 20s deadline
and surfaced as "Kiro CLI timed out." — even though the same commands
return in ~2-4s from a real terminal.

Route every kiro-cli invocation through TTYCommandRunner (PTY), matching
the Codex/Claude status probes. The existing parser handles the PTY output
unchanged. The now-orphaned `isUsageOutputComplete` helper is removed; the
pipe-based `runCommand` is left in place (still covered by its own tests).

steipete#1627 only made /usage independent of the slow account probe and was never
validated against real kiro-cli, so the timeout persisted on 2.8.1.

Fixes steipete#1619.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed June 26, 2026, 6:48 PM ET / 22:48 UTC.

Summary
This PR routes Kiro whoami, usage, and context probes through the shared PTY runner, extends PTY/process cleanup and completion tracking, and adds Kiro regression tests.

Reproducibility: yes. at source/report level: the linked report gives a Kiro 2.8.1 timeout path, and current main still uses the pipe-backed Kiro command path. I did not run a live provider probe because AGENTS.md requires explicit request for that.

Review metrics: 3 noteworthy metrics.

  • Changed files: 4 files affected. The diff spans the Kiro provider, shared PTY/process infrastructure, and tests rather than a parser-only change.
  • Kiro invocations moved: 3 production commands. whoami, /usage, and /context all change transport and completion/failure semantics.
  • Latest check rollup: 3 succeeded, 6 in progress. Maintainers should wait for the current-head Linux and macOS jobs before merging.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #1619
Summary: This PR is a candidate fix for the Kiro 2.8.1 timeout reported in the related issue; the earlier merged PR addressed account-probe races but left the pipe-backed command launch path in place.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Wait for the in-progress CI jobs on the latest head to finish before merge.
  • Have a maintainer explicitly accept the shared PTY runner and Kiro provider behavior change.

Risk before merge

  • [P1] The PR changes shared PTY launch and cleanup behavior, so Codex/Claude/Kiro process lifetime behavior should get normal maintainer scrutiny even though the Kiro fix is focused.
  • [P1] Kiro account and usage failure classification moves from pipe-backed stdout/stderr capture to PTY completion semantics, which can affect auth/provider error surfacing.
  • [P1] The latest head still has two Linux build jobs and four macOS Swift test shards in progress, so merge should wait for the check rollup to finish.

Maintainer options:

  1. Review And Land The PTY Path (recommended)
    After CI completes, maintainers can merge if they accept that Kiro now uses PTY completion/auth semantics and the shared runner cleanup model.
  2. Request A Maintainer Smoke Before Merge
    A maintainer can require one fresh redacted packaged-app or CLI smoke proof on the latest head if they want more confidence in live Kiro behavior.
  3. Pause For A Narrower Transport Change
    If the shared TTY runner refactor feels too broad for this provider fix, pause this PR and ask for a smaller Kiro-only transport patch.

Next step before merge

  • [P2] No narrow automated repair remains from this review; the remaining action is maintainer review and merge gating.

Security
Cleared: No dependency, workflow, secret, publishing, or external-download changes were found; the security pass found no concrete supply-chain concern.

Review details

Best possible solution:

Land the PTY-based Kiro fix after latest checks complete and a maintainer accepts the shared PTY/process cleanup behavior for provider probes.

Do we have a high-confidence way to reproduce the issue?

Yes at source/report level: the linked report gives a Kiro 2.8.1 timeout path, and current main still uses the pipe-backed Kiro command path. I did not run a live provider probe because AGENTS.md requires explicit request for that.

Is this the best way to solve the issue?

Yes, PTY transport is the narrowest maintainable shape for a CLI that emits output only with a terminal, and current head now preserves exit status, idle-output checks, cancellation, and detached-helper cleanup. The remaining work is maintainer acceptance and completed checks, not a new code finding.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e4e97f9bc44c.

Label changes

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports after-fix real kiro-cli 2.8.1 and packaged-app behavior where Kiro usage returned in seconds and no residual Kiro processes remained.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority Kiro provider timeout fix with bounded blast radius but real provider usability impact.
  • merge-risk: 🚨 auth-provider: The diff changes how Kiro account and usage CLI commands are launched and how auth-related failures are classified.
  • merge-risk: 🚨 availability: The diff changes shared PTY process launch and cleanup behavior, including residual helper termination.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports after-fix real kiro-cli 2.8.1 and packaged-app behavior where Kiro usage returned in seconds and no residual Kiro processes remained.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports after-fix real kiro-cli 2.8.1 and packaged-app behavior where Kiro usage returned in seconds and no residual Kiro processes remained.
Evidence reviewed

What I checked:

Likely related people:

  • steipete: Recent history includes Kiro helper-process cleanup, shared PTY child-process cleanup, and the latest repair commits on this PR's process/provider surface. (role: recent area contributor; confidence: high; commits: 3286934b8be3, d9b607b1f80a, 9c8a9a667329; files: Sources/CodexBarCore/Providers/Kiro/KiroStatusProbe.swift, Sources/CodexBarCore/Host/PTY/TTYCommandRunner.swift, Sources/CodexBarCore/Host/Process/SpawnedProcessGroup.swift)
  • kiranmagic7: Authored recent Kiro usage command pipe-hang work in the same provider failure family. (role: adjacent Kiro process contributor; confidence: medium; commits: 209b6c857fad; files: Sources/CodexBarCore/Providers/Kiro/KiroStatusProbe.swift, Tests/CodexBarTests/KiroStatusProbeTests.swift)
  • Nathan Eror: Introduced the Kiro provider and its initial usage-probe tests, making this person useful historical context for provider expectations. (role: introduced behavior; confidence: medium; commits: bbda93528714; files: Sources/CodexBarCore/Providers/Kiro/KiroStatusProbe.swift, Tests/CodexBarTests/KiroStatusProbeTests.swift)
  • Ratul Sarna: Recent PTY post-exit drain and shutdown stabilization work is relevant because this PR changes shared TTY runner and process cleanup behavior. (role: adjacent PTY runner contributor; confidence: medium; commits: ed32c67eb613, 0f7d07176de8, 9bb4174908d7; files: Sources/CodexBarCore/Host/PTY/TTYCommandRunner.swift, Tests/CodexBarTests/TTYCommandRunnerTests.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ac29c3751

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/Providers/Kiro/KiroStatusProbe.swift Outdated
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 24, 2026
sf-jin-ku and others added 3 commits June 24, 2026 12:42
The PTY runner cannot surface the child exit status, so a non-zero
`kiro-cli whoami` that prints a non-login error (config/network) would be
parsed as a logged-in account with empty fields. Reject output carrying no
account markers so the best-effort account probe reports it as unavailable.

Addresses Codex review feedback on steipete#1744.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9424144fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/Providers/Kiro/KiroStatusProbe.swift
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 26, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 26, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40140a3181

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/Host/Process/SpawnedProcessGroup.swift Outdated
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 26, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 26, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 26, 2026
@steipete

Copy link
Copy Markdown
Owner

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@steipete steipete merged commit da693aa into steipete:main Jun 26, 2026
10 checks passed
@steipete

Copy link
Copy Markdown
Owner

Landed in da693aa7; maintainer changelog credit followed in c089c121.

Proof: exact-head CI run 28269408114 passed lint, GitGuardian, Linux x64/arm64 builds and tests, all four macOS test shards, and the aggregate gate. Local proof also passed make check, the full 43-shard make test, focused Kiro/PTY/process-group suites, and autoreview with no actionable findings.

No additional credentialed Kiro probe was run; the merge relies on the PR's existing real Kiro 2.8.1 and packaged-app proof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kiro provider times out with kiro-cli 2.8.1, while /usage returns in 4s

2 participants